]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Make _loadCategory() a utility function
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 31 Jan 2013 14:16:25 +0000 (15:16 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 19 Feb 2013 23:08:11 +0000 (00:08 +0100)
When we bring back categories as folders, this method will be
useful outside of AppDisplay.

https://bugzilla.gnome.org/show_bug.cgi?id=694192

js/ui/appDisplay.js

index b968fabcfcf5c082cb08eb2113718fa9fd839114..456feb563b74a23940f6e90acd99b0970a7ddcb0 100644 (file)
@@ -28,6 +28,25 @@ const MAX_APPLICATION_WORK_MILLIS = 75;
 const MENU_POPUP_TIMEOUT = 600;
 const SCROLL_TIME = 0.1;
 
+// Recursively load a GMenuTreeDirectory; we could put this in ShellAppSystem too
+function _loadCategory(dir, view) {
+    let iter = dir.iter();
+    let appSystem = Shell.AppSystem.get_default();
+    let nextType;
+    while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) {
+        if (nextType == GMenu.TreeItemType.ENTRY) {
+            let entry = iter.get_entry();
+            let app = appSystem.lookup_app_by_tree_entry(entry);
+            if (!entry.get_app_info().get_nodisplay())
+                view.addApp(app);
+        } else if (nextType == GMenu.TreeItemType.DIRECTORY) {
+            let itemDir = iter.get_directory();
+            if (!itemDir.get_is_nodisplay())
+                _loadCategory(itemDir, view);
+        }
+    }
+};
+
 const AlphabeticalView = new Lang.Class({
     Name: 'AlphabeticalView',
 
@@ -132,24 +151,6 @@ const AppDisplay = new Lang.Class({
         this._workId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._redisplay));
     },
 
-    // Recursively load a GMenuTreeDirectory; we could put this in ShellAppSystem too
-    _loadCategory: function(dir) {
-        var iter = dir.iter();
-        var nextType;
-        while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) {
-            if (nextType == GMenu.TreeItemType.ENTRY) {
-                var entry = iter.get_entry();
-                var app = this._appSystem.lookup_app_by_tree_entry(entry);
-                if (!entry.get_app_info().get_nodisplay())
-                    this._view.addApp(app);
-            } else if (nextType == GMenu.TreeItemType.DIRECTORY) {
-                var itemDir = iter.get_directory();
-                if (!itemDir.get_is_nodisplay())
-                    this._loadCategory(itemDir);
-            }
-        }
-    },
-
     _removeAll: function() {
         this._view.removeAll();
     },
@@ -168,7 +169,7 @@ const AppDisplay = new Lang.Class({
                 if (dir.get_is_nodisplay())
                     continue;
 
-                this._loadCategory(dir);
+                _loadCategory(dir, this._view);
             }
         }